//
//  BaseInfoEditTextCell.m
//  CenturyCity
//
//  Created by beisheng03 on 2018/1/9.
//  Copyright © 2018年 beisheng. All rights reserved.
//

#import "BaseInfoEditTextCell.h"
@interface BaseInfoEditTextCell ()
@property (weak, nonatomic) IBOutlet UILabel *leftLabel;
@property (weak, nonatomic) IBOutlet UITextField *rightTextField;

@end
@implementation BaseInfoEditTextCell

- (void)awakeFromNib {
    [super awakeFromNib];
    self.leftLabel.font = MYFONT(15);
    
    self.rightTextField.font = MYFONT(15);
    
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.rightTextField];

    // Initialization code
}

- (void)setIndex:(NSIndexPath *)index{
    _index = index;
    
    if (_index.row == 1) {
        self.leftLabel.text = @"用户名";
        self.rightTextField.userInteractionEnabled = NO;
    } else if (_index.row == 2) {
        self.leftLabel.text = @"昵称";
        
        self.rightTextField.userInteractionEnabled = YES;

    }else{
        
         self.leftLabel.text = @"修改密码";
         self.rightTextField.userInteractionEnabled = NO;

    }
    
    
    
}

- (void)setModel:(EditMyInforModel *)model{
    
    _model = model;
    
    self.rightTextField.hidden = NO;
    
    self.accessoryType = UITableViewCellAccessoryNone;
    
    if (self.index.row == 1) {
        
        self.rightTextField.text = myViewModel.user.user_tel;
        
        

    }else if (self.index.row == 2){
        
        self.rightTextField.text = _model.nickName;

        
    }else{
        
        
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        self.rightTextField.hidden = YES;
    }
    
}







- (void)textChange{
    
    if (self.index.row == 2) {
        
        self.model.nickName = self.rightTextField.text;

    }
    
    
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
